//
//  NullData.swift
//  Exam-iOS
//
//  Created by lishengfeng on 2018/4/14.
//  Copyright © 2018年 李胜锋. All rights reserved.
//

import UIKit
import SnapKit
import Then

protocol NullData {
    
}

extension NullData {
    
    
    func nilView(text: String = "暂无内容", imageName: String = "空") -> UIView {
        let view = UIView()
        
        let containerView = UIView().then { (v) in
            v.backgroundColor = UIColor.clear
            
            view.addSubview(v)
            v.snp.makeConstraints({ (maker) in
                maker.center.equalToSuperview()
            })
        }
        
        let imageView = UIImageView().then { (imgView) in
            imgView.image = UIImage.init(named: imageName)
            imgView.backgroundColor = UIColor.lsf_color16(0xd3d3d3)
            imgView.clipsToBounds = true
            imgView.layer.cornerRadius = 40
            imgView.contentMode = .center
            
            containerView.addSubview(imgView)
            imgView.snp.makeConstraints({ (maker) in
                maker.top.equalToSuperview()
                maker.centerX.equalToSuperview()
                maker.size.equalTo(CGSize.init(width: 80, height: 80))
            })
        }
        
        _ = UILabel().then { (label) in
            label.textAlignment = .center
            label.textColor = UIColor.lsf_color16(0xd3d3d3)
            label.text = text
            
            containerView.addSubview(label)
            label.snp.makeConstraints({ (maker) in
                maker.top.equalTo(imageView.snp.bottom).offset(10)
                maker.centerX.equalToSuperview()
                maker.bottom.equalToSuperview()
                maker.width.greaterThanOrEqualTo(44)
                maker.leading.trailing.greaterThanOrEqualToSuperview()
            })
        }
        
        return view
    }
}
